#! /bin/sh

which perl 2>&1 >/dev/null || exit 1
which grep 2>&1 >/dev/null || exit 1
which sed  2>&1 >/dev/null || exit 1

echo
echo -n '#define ngx_javascript_version_string "nginx+javascript/0.2.'`date +%Y%m%d`'"'
echo
for f in *.c; do
  [ "$f" = "ngx_javascript_module_file.c" ] && continue
  [ "$f" = "ngx_javascript_module_mysql.c" ] && continue
  [ "$f" = "ngx_javascript_module_sqlite.c" ] && continue
  cat "$f" | perl -ne 'print if m,^[a-zA-Z].* {,' | grep -v '=' | sed -e 's, {$,;,'
done
